﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Reflection;
using System.Xml;

namespace WindowsService
{
    [RunInstaller(true)]
    public partial class ProjectInstaller : System.Configuration.Install.Installer
    {
        public ProjectInstaller()
        {
            InitializeComponent();
            this.serviceInstaller1.ServiceName = getXmlData("SerName");
            this.serviceInstaller1.Description = getXmlData("SerDes");
        }
        public static string getXmlData(string type)
        {
            string strxml = "";
            XmlDocument xml = new XmlDocument();
            //获取到文件完整路径 
            string path = Assembly.GetExecutingAssembly().Location;
            string[] zz = path.Split('\\');
            string pa = "";
            for (int i = 0; i < zz.Length - 1; i++)
            {
                pa += zz[i] + "\\";
            }
            xml.Load(pa + "\\Dcxt.config");
            XmlNodeList xmldebug = xml.GetElementsByTagName(type);
            if (xmldebug.Count > 1)
            {
                for (int i = 0; i < xmldebug.Count; i++)
                {
                    strxml += xmldebug[i].InnerText.Trim() + ";";
                }
            }
            else
            {
                strxml = xmldebug[0].InnerText.Trim();
            }
            return strxml;
        }
    }
}
